import { requestClient } from '#/api/request';

/**
 * 查询认证信息
 * @param {string|number} id 认证ID
 * @returns {Promise<any>}
 */
export async function getCertificationInfoByIdApi(id: string | number) {
  return requestClient.get(`/certification/get-certification-info/${id}`);
}

/**
 * 查询用户是否已经有购买认证订单
 * @param {string|number} userId 用户ID
 * @param {string|number} certificateId 认证ID
 * @returns {Promise<any>}
 */
export async function getCertOrderApi(userId: string | number, certificateId: string | number) {
  return requestClient.get('/certification/get-cert-order', {
    params: {
      userId,
      certificateId,
    },
  });
}

/**
 * 创建用户认证订单
 * @param {Object} data 订单参数
 * @param {string} data.userId 用户ID
 * @param {string} data.certificateId 认证ID
 * @param {string} data.buyMethod 购买方式
 * @param {number} data.quantity 购买数量
 * @param {string} data.amount 金额
 * @returns {Promise<any>}
 */
export async function createUserCertOrderApi(data: {
  userId: string;
  certificateId: string;
  buyMethod: string;
  quantity: number;
  amount: string;
}) {
  return requestClient.post('/certification/create-user-cert-order', data);
}

/**
 * 获取原生支付二维码
 * @param {Object} params 请求参数
 * @param {string|number} params.orderId 订单ID
 * @returns {Promise<any>}
 */
export async function getNativeCodeApi(orderId: string | number) {
  return requestClient.get('/certification/get-native-code', {
    params: {
      orderId,
      payOption: 'WxPay',
      payType: 'SCANPAY',
    }
  });
}

/**
 * 查询支付结果
 * @param {string|number} orderId 订单ID
 * @returns {Promise<any>}
 */
export async function getPayResultApi(orderId: string | number) {
  return requestClient.get('/certification/get-pay-result', {
    params: {
      orderId
    }
  });
}


